home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue45 / Clinic / Server_Stub2.pas < prev    next >
Pascal/Delphi Source File  |  2000-11-02  |  2KB  |  60 lines

  1. unit Server_Stub2;
  2.  
  3. interface
  4.  
  5. uses
  6.   CorbaObj, OrbPas;
  7.  
  8. type
  9.   ITest = interface
  10.     ['{6B0BEBC1-40B4-11D2-8684-0020182CD6A0}']
  11.     function Get_DateAndTime: TDateTime;
  12.   end;
  13.  
  14.   TTestStub = class(TCorbaStub, ITest)
  15.     function Get_DateAndTime: TDateTime;
  16.   end;
  17.  
  18.   ITestFactory = interface
  19.     ['{2270CD21-D63E-11D2-96EC-0060978E1359}']
  20.     function CreateInstance(const InstanceName: String): ITest;
  21.   end;
  22.  
  23.   TTestFactoryStub = class(TCorbaStub, ITestFactory)
  24.     function CreateInstance(const InstanceName: String): ITest;
  25.   end;
  26.  
  27. implementation
  28.  
  29. { TTestStub }
  30.  
  31. function TTestStub.Get_DateAndTime: TDateTime;
  32. var
  33.   OutBuf: IMarshalOutBuffer;
  34.   InBuf: IMarshalInBuffer;
  35. begin;
  36.   FStub.CreateRequest('Get_DateAndTime', True, OutBuf);
  37.   FStub.Invoke(OutBuf, InBuf);
  38.   Result := InBuf.GetDouble;
  39. end;
  40.  
  41. { TTestFactoryStub }
  42.  
  43. function TTestFactoryStub.CreateInstance(const InstanceName: String): ITest;
  44. var
  45.   OutBuf: IMarshalOutBuffer;
  46.   InBuf: IMarshalInBuffer;
  47. begin;
  48.   FStub.CreateRequest('CreateInstance', True, OutBuf);
  49.   OutBuf.PutText(PChar(InstanceName));
  50.   FStub.Invoke(OutBuf, InBuf);
  51.   Result := UnmarshalObject(InBuf, ITest) as ITest;
  52. end;
  53.  
  54. initialization
  55.   CorbaStubManager.RegisterStub(ITest, TTestStub);
  56.   CorbaInterfaceIDManager.RegisterInterface(ITest, 'IDL:Server/Test:1.0');
  57.   CorbaStubManager.RegisterStub(ITestFactory, TTestFactoryStub);
  58.   CorbaInterfaceIDManager.RegisterInterface(ITestFactory, 'IDL:Server/TestFactory:1.0');
  59. end.
  60.